package com.heima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import com.heima.pojo.dto.PageDTO;
import com.heima.pojo.entity.Partner;
import com.heima.pojo.vo.PartnerVO;
import org.apache.ibatis.annotations.*;

/**
 * \* User: chy
 * \* Date: 2025/8/17   10:14
 * \* Description:
 * \
 */
@Mapper
public interface PartnerMapper  extends BaseMapper<Partner> {
    /*
    * 合作商分页查询
    * */
    Page<PartnerVO> page(PageDTO partnerDTO);

    @Insert("insert into tb_partner (name,password,account,mobile,phone,email,province,city,county,addr,contact,ratio,status,create_time,update_time) " +
            "values (#{name},#{password},#{account},#{mobile},#{phone},#{email},#{province},#{city},#{county},#{addr},#{contact},#{ratio},#{status},#{createTime},#{updateTime})")
    void add(Partner partner);

    //TODO  这里设备数量没有
    @Select("select tp.id,tp.name,tp.account,tp.ratio,tp.contact,tp.phone,tp.mobile from tb_partner tp where id = #{id}")
    Partner getById(Integer id);



    /*
    * 删除合作商
    * */
    @Delete("delete from tb_partner where id = #{id}")
    void deleteById(Integer id);

    @Select("select  count(*) from tb_partner where name =#{name}")
    int getByName(String name);
}
